﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SecurityAgent;
using SecurityAgent.Client;

namespace SecurityAgentServiceWinFormClientTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void loginControl1_LoginEvent(object sender, SecurityAgent.Client.WinForm.LoginEventArgs e)
        {
            if (e.Authenticated)
            {
                txtOutput.Text += "User " + SASPrincipal.Current.Identity.Name + " Is Authenticated\n";
                txtOutput.Text += "User " + SASPrincipal.Current.Identity.Name + (SASPrincipal.Current.IsInRole("Admin") ? " Is " : " Is Not ") + " In The Admin Role\n";
                txtOutput.Text += "Facility : " + SASPrincipal.Current.GetProfilePropertyValue("Facility");
                txtOutput.Text += "Object Supplier Quality: " + (SASPrincipal.Current.CheckObjectAccess("SupplierQuality").AllowRead? "Allow Read " : "Deny Read") + "\n";
                txtOutput.Text += "Object Customer Quality: " + (SASPrincipal.Current.CheckObjectAccess("CustomerQuality").AllowRead? "Allow Read " : "Deny Read") + "\n";
            }
        }
    }
}
